ACM ICPC::Regional Warmup 1 (Easy version) + Algunos cambios en el manual
[and.git] / Mi manual de algoritmos / version_maraton_interuniversitaria_2008-2 / src / number_theory / criba.cpp
blob129bfa8c1eaa9de27915439546d2025536a5358a
1 #include <iostream>
3 const int SIZE = 1000000;
5 //criba[i] = false si i es primo
6 bool criba[SIZE+1];
8 void buildCriba(){
9 memset(criba, false, sizeof(criba));
11 criba[0] = criba[1] = true;
12 for (int i=2; i<=SIZE; i += 2){
13 criba[i] = true;
16 for (int i=3; i<=SIZE; i += 2){
17 if (!criba[i]){
18 for (int j=i+i; j<=SIZE; j += i){
19 criba[j] = true;